#！bin/bash
#set -x

basepath=$(cd `dirname $0`; pwd)

main() {
    buildType=$1
    cd $basepath/..
    mkdir jars

    cd $basepath/../hadoop-tools/hadoop-huaweicloud/
    mvn clean install -Pdist -Dhadoop.plat.version=2.8.3 -Dhadoop.version=2.8.3.0101-hw-ei-14 -Dmaven.test.skip=true
    mv target/hadoop-huaweicloud-* $basepath/../jars/.

    cd $basepath/../hadoop-tools/hadoop-huaweicloud/
    mvn clean compile test-compile assembly:single -Ddescriptor=$basepath/../hadoop-tools/hadoop-huaweicloud/src/test/resources/assembly.xml -f pom.xml -Pdist -Dhadoop.plat.version=2.8.3 -Dhadoop.version=2.8.3.0101-hw-ei-14
    mv target/hadoop-huaweicloud-* $basepath/../jars/.

    cd $basepath/../hadoop-tools/hadoop-huaweicloud/
    mvn clean package -Dmaven.test.skip=true -Dhadoop.plat.version=3.1.1 -Dhadoop.version=3.1.1-hw-ei-311006 -P dist
    cp target/hadoop-huaweicloud-* $basepath/../jars/.

    cd $basepath/../flink-obs-fs-hadoop
    mvn clean package -DskipTests -Dhadoop.version=3.1.1-hw-ei-311006 -P ITTest -f pom.xml
    mv target/flink-obs-fs-hadoop-* $basepath/../jars/.

    cd $basepath/../jars
    cur_time=`date +%Y%m%d%H%M`
    # tar cvf OBSA${cur_time}.tar.gz -C $basepath/../jars
    tar cvf OBSA${cur_time}.tar.gz hadoop-huaweicloud-* flink-obs-fs-hadoop-*
}

main $@
